<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <jsp:include page="find.jsp" flush="true"></jsp:include>
        <div class="layui-form-item">
            <table class="layui-table" id="newstable">
                <thead>
                <tr>
                    <th scope="col">ID</th>
                    <th scope="col">标题</th>
                    <th scope="col">作者</th>
                    <th scope="col">时间</th>
                    <th scope="col">添加者</th>
                    <th scope="col">图片</th>
                    <th scope="col">主要内容</th>
                    <th scope="col">类别</th>
                    <th scope="col">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="news" items="${pageNews}" varStatus="s">
                    <form method="post">
                        <input type="hidden" name="id" value="${news.id}"/>
                        <tr>
                            <th scope="row">${s.index+1}</th>
                            <td>${news.title}</td>
                            <td>${news.author}</td>
                            <td>${news.datetime}</td>
                            <td>${news.adder}</td>
                            <td>${news.picadr}</td>
                            <td>${news.main}</td>
                            <td>${news.category}</td>
                            <td><a  class="layui-btn layui-btn-xs" lay-event="edit"
                                   href="/ShowNewsInfo?id=${news.id}">编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"
                                   href="/DelNews?id=${news.id}">删除</a>
                        </tr>
                    </form>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <div class="layui-form-item">
            <a type="button" class="layui-btn  layui-btn-xs" href="ShowAllNews?pageIndex=1">首页</a>
            <c:if test="${currentPageIndex!=1}">
                <a type="button" class="layui-btn layui-btn-normal layui-btn-xs"
                   href="ShowAllNews?pageIndex=${currentPageIndex-1}">上一页</a>
            </c:if>
            <c:if test="${currentPageIndex!=pageCount}">
                <a type="button" class="layui-btn layui-btn-warm layui-btn-xs"
                   href="ShowAllNews?pageIndex=${currentPageIndex+1}">下一页</a>
            </c:if>
            <a type="button" class="layui-btn  layui-btn-xs" href="ShowAllNews?pageIndex=${pageCount}">尾页</a>
            <p style="color: white">共${newsCount}条记录，每页显示${countPerPage}条记录，共${pageCount}页，当前是第${currentPageIndex}页 </p>
        </div>
    </div>
</div>
